<%@ page language="java" contentType="text/html; charset=UTF-8" 
import="java.util.*,jspsmart.upload.*,java.text.SimpleDateFormat,javax.servlet.ServletConfig"
    pageEncoding="UTF-8"%>
<%@ page import="util.*" %>
<%@ page import="model.*" %>
<%@ page import="control.*" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>resources_download_chuli.jsp</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
    <%
            request.setCharacterEncoding("UTF-8");
            String id=request.getParameter("id");
            Resources resources=new Resources();
            
            
         //   int id=ParamUtil.getInt(request,"id",0);
			SmartUpload mySmartdownload = new SmartUpload();
			String downfile="/resources/resources/"+request.getParameter("downfile");
			try{
      			 response.reset();
	 			 out.clear();
	 			 out = pageContext.pushBody();
     			 mySmartdownload.initialize(pageContext);
     			 mySmartdownload.setContentDisposition(null);
    			 mySmartdownload.downloadFile(downfile);
    			 int times= resources.getDownloadtimes()+1;
    			 ResourcesControl rsc=new ResourcesControl();
    			 resources.setDownloadtimes(times);
    			 rsc.updateResourcesDownloadtimes(resources,Integer.parseInt(id));
    			 //response.sendRedirect("/bluemsun/pages/subpages/resources.jsp");
    			 System.out.println("my");
 			 }catch(Exception e){
		  	String errors="<li>文件下载失败：请检查选择的文件是否存在？</li>";
      	    request.setAttribute("errors",errors);
    	    RequestDispatcher rd=request.getRequestDispatcher("../subpages/resources.jsp");
     	    rd.forward(request,response);
  		  }
		 %>
  </body>
</html>
